layui.define([ 'form', 'laydate', 'table' ], function(exports) {
    var form = layui.form;
    var laydate = layui.laydate;
    var table = layui.table;
    var entryTable = null;
    var view ={
        init:function(){
            this.initTable();
            this.initSearchForm();
            this.initToolBar();
            window.dataReload = function(){
                Lib.doSearchForm($("#searchForm"),entryTable)
            }
        },
        initTable:function(){
            entryTable = table.render({
                elem : '#entryTable',
                height : Lib.getTableHeight(1),
                cellMinWidth: 100,
                method : 'post',
                url : Common.ctxPath + '/cms/entry/Acceptancelist.json' // 数据接口
                ,page : Lib.tablePage // 开启分页
                ,limit : 10,
                cols : [ [ // 表头
                    {
                        type : 'checkbox',
                        fixed:'left',
                    },
                    {

                        field : 'id',
                        title : 'Id',
                        fixed:'left',
                        width : 60,
                    },
                    {

                        field : 'name',
                        title : '姓名',
                        align: 'center',
                        width:"120"
                    },
                    {

                        field : 'entryUnit',
                        title : '入职单位',
                        align: 'center',
                        width:"165"
                    },
                    {

                        field : 'position',
                        title : '职位',
                        align: 'center',
                        width:"120"
                    },
                    {

                        field : 'businessState',
                        title : '业务状态',
                        align: 'center',
                        width:"135"
                    },
                {

                    field : 'dateReporting',
                        title : '上报日期',
                    align: 'center',
                    width:"165"
                }

        ] ]

        });

            table.on('checkbox(entryTable)', function(obj){
                var entry = obj.data;
                if(obj.checked){
                    //按钮逻辑Lib.buttonEnable()
                }else{

                }
            })
        },

        initSearchForm:function(){
            Lib.initSearchForm( $("#searchForm"),entryTable,form);
        },
        initToolBar:function(){
            toolbar = {
                add : function() { // 获取选中数据
                    var url = "/cms/entry/add.do";
                    Common.openDlg(url,"入职>新增");
                },
                edit : function() { // 获取选中数目
                    var data = Common.getOneFromTable(table,"entryTable");
                    if(data==null){
                        return ;
                    }
                    var url = "/cms/entry/edit.do?id="+data.id;
                    Common.openDlg(url,"入职>编辑");
                },
                find : function() { // 获取选中数目
                    var data = Common.getOneFromTable(table,"entryTable");
                    if(data==null){
                        return ;
                    }
                    var url = "/cms/entry/findenterprise.do?id="+data.id;
                    Common.openDlg(url,"入职受理>查看");
                },
                process : function() { // 获取选中数目
                    var businessType = Common.businessType.entry;

                    var data = Common.getOneFromTable(table,"entryTable");
                    if(data==null){
                        return ;
                    }
                    var url = "/cms/businessProcess/index.do?businessType="+businessType+"&businessId="+data.id;
                    Common.openDlg(url,"流程信息>编辑");
                },
                acceptance : function() { // 获取选中数目
                    var data = Common.UnableToFirstTrial(table,"entryTable");
                    if(data==null){
                        return ;
                    }
                    var url = "/cms/entry/acceptance.do?id="+data.id;
                    Common.openDlg(url,"入职受理>受理");
                },
                del : function() {
                    layui.use(['del'], function(){
                        var delView = layui.del
                        delView.delBatch();
                    });
                }
        };
            $('.ext-toolbar').on('click', function() {
                var type = $(this).data('type');
                toolbar[type] ? toolbar[type].call(this) : '';
            });
        }
    }
    exports('enterprise',view);

});